import { reGoodsInfo,reqAddOrUpdateShopCart} from "@/api"
import { getUUID } from "@/utils/uuid_token"
const state={
  goodsInfo:{},
  getAddCart:{},
  uuid_token:getUUID()
}
const mutations={
  GetGoods(state,goodsList){
   
    state.goodsInfo=goodsList
  },
 
}
const actions={
  async goodsList({commit},skuId){
    let result=await reGoodsInfo(skuId)
    
   if(result.code==200){
     commit("GetGoods",result.data)
   }
  },
  async shoppingCart({commit},{skuId,skuNum}){
    let result=await reqAddOrUpdateShopCart(skuId,skuNum)

    if(result.code==200){
     return "ok"
   }
  }
}
const getters={
  categoryView(state){
    return state.goodsInfo.categoryView||{}
  },
  skuInfo(state){
    return state.goodsInfo.skuInfo||{}
  },
   spuSaleAttrList(state){
    return state.goodsInfo.spuSaleAttrList||[]
  },
}
export default{
  
  state,
  mutations,
  actions,
  getters
}